"""视频相关的数据模型"""
from typing import Optional
from datetime import datetime
from pydantic import BaseModel


class VideoBase(BaseModel):
    """视频基础模型"""
    title: str
    description: Optional[str] = None
    cover_url: Optional[str] = None
    video_url: str
    duration: Optional[int] = None
    category_id: int


class VideoCreate(VideoBase):
    """创建视频模型"""
    pass


class VideoUpdate(BaseModel):
    """更新视频模型"""
    title: Optional[str] = None
    description: Optional[str] = None
    cover_url: Optional[str] = None
    category_id: Optional[int] = None


class VideoResponse(BaseModel):
    """视频响应模型"""
    id: int
    title: str
    description: Optional[str] = None
    cover_url: Optional[str] = None
    video_url: str
    duration: Optional[int] = None
    category_id: int
    user_id: int
    username: str
    nickname: Optional[str] = None
    avatar: Optional[str] = None
    view_count: int
    like_count: int
    collect_count: int
    comment_count: int
    
    class Config:
        from_attributes = True


class VideoDetailResponse(VideoResponse):
    """视频详情响应模型"""
    category_name: Optional[str] = None
    is_liked: Optional[bool] = False
    is_collected: Optional[bool] = False
